#include <stdio.h>
#include<stdlib.h>
#include"Queues.h"
#include<time.h>




int main1()
{

    struct my{
        int num;
        struct list_head list;
    };
    /*
    struct my *head =malloc(sizeof (struct my));
    INIT_LIST_HEAD(&head->list);

    for (int i=1;i<=10;i++) {
        struct my *t =malloc(sizeof (struct my));
        t->num=i;
        list_add(&t->list,&head->list);
    }
    struct my *head1 =malloc(sizeof (struct my));
    INIT_LIST_HEAD(&head1->list);
    for (int i=200;i<=210;i++) {
        struct my *t =malloc(sizeof (struct my));
        t->num=i;
        list_add(&t->list,&head1->list);
    }
    list_splice(&head1->list,&head->list);


    struct list_head *temp;
    list_for_each_prev(temp,&head->list){
        if(container_of(temp,struct my,list)->num==6)break;
    }
    list_del(temp);
    free(container_of(temp,struct my,list));
    list_for_each_prev(temp,&head->list){
        printf("%d\n",container_of(temp,struct my,list)->num);
    }
*/

struct my que;
INIT_LIST_HEAD(&que.list);
getchar();
srand((unsigned)time(NULL));
for(int i=0;i<100000;i++){
    struct my *data1=malloc(sizeof (struct my));
    data1->num=rand();
    queues_push(&que.list,&data1->list);
}
printf("size=%d\n",queues_size(&que.list));
//    getchar();
//    for(int i=0;i<100;i++){
//        struct list_head* t=queues_pop(&que.list);
//        printf("%d--%d---size=%d\n", queues_isempty(&que.list),container_of(t,struct my,list)->num,queues_size(&que.list));
//        free(container_of(t,struct my,list));
//    }
//    getchar();


struct list_head* temp1;

list_for_each(temp1,&que.list){
    struct list_head* temp2;
    list_for_each(temp2,&que.list)
            if(container_of(temp2,struct my,list)->num<container_of(temp1,struct my,list)->num){
        int temp=container_of(temp2,struct my,list)->num;
        container_of(temp2,struct my,list)->num=container_of(temp1,struct my,list)->num;
        container_of(temp1,struct my,list)->num=temp;
    }
}


list_for_each(temp1,&que.list){
    printf("%d--%d---size=%d\n", queues_isempty(&que.list),container_of(temp1,struct my,list)->num,queues_size(&que.list));

}
return 0;
}

